This is an example of vertical and horizontal centering:
This course is a lot of fun. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.
window object represents an open window in a browser.
This object has many properties including the dimension of the window.
Find the properties, such as innerWidth and innerHeight, from The Window Object.
window.addEventListener('resize', listener);
<style>
p { background-color: SkyBlue; }
p.left { width: 70%; margin-right: auto; }
p.right { width: 70%; margin-left: auto; }
p.horizontal-center { width: 400px; margin: auto; }
p.just { margin-top: 40px; margin-bottom: 20px; margin-left: 100px; margin-right: 50px; }
p.inside { width: 60%; margin: auto; margin-top:20px; }
</style>
<p>This course is a lot of fun. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.</p>
<p class='left'>This course is a lot of fun. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.</p>
<p class='right'>This course is a lot of fun. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.</p>
<p class='horizontal-center'>This course is a lot of fun. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.</p>
<p class='just'>This course is a lot of fun. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.</p>
<div style='width:80%; height:200px; border: 5px solid Blue;'>
<p class='inside'>This course is a lot of fun. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.</p>
</div>
calc()'.
It supports simple arithmetic operations in CSS.
calc(50vw-55px) does not work because 50vw-55px will be considered as an identifier in CSS styling.
It should be calc(50vw - 55px). Spaces around '-' are necessary.
<p style='width:250px; position:fixed; top:25%; left:???(????); background-color:Grey; text-align:center; z-index:1; font-size:200%'>
<a href='//cs.tru.ca'>cs.tru.ca</a>
</p>
<style>
div.outside { position:relative; ???:???; ???:???; width:400px; height:200px; border:1px solid blue; }
</style>
<p>This course is a lot of fun. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.</p>
<div class='outside'>
<div style='border:1px solid black; text-align:center; width:60%; height:100px; position:relative; ????'>This course is a lot of fun. This course is a lot of fun. This course is a lot of fun. This course is a lot of fun.</div>
</div>
domobj.offsetWidth, offsetHeight, parentElement. You may read The HTML DOM Element Object.